// ---------------------------------------------------------------------
//
// -- 六边形格子
// -- author £
//
// ---------------------------------------------------------------------

const FADE_TIME = 0.3;

cc.Class({
    extends: cc.Component,

    properties: {
        hl: cc.Node,
        item: cc.Node,
        sfs: {
            default: [],
            type: cc.SpriteFrame
        }
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        this.hl.active = false;
        this.item.active = false;
    },

    start () {

    },

    reset: function () {
        this.hl.active = false;
        this.item.active = false;
        this.item.stopAllActions();
        this.item.opacity = 255;
    },

    setHL: function (flag) {
        this.hl.active = flag;
        
        if (flag) {
            this.item.active = false;
        }
    },

    setGrid: function (colorIndex) {
        let itemSp = this.item.getComponent(cc.Sprite);

        itemSp.spriteFrame = this.sfs[colorIndex];
        this.item.stopAllActions();
        this.item.active = true;
        this.item.opacity = 255;
        this.hl.active = false;
    },

    erase: function (delay) {
        this.item.opacity = 255;
        require('ActionLib').FADE_HIDE(this.item,
            FADE_TIME,
            delay, null, null, null, true);
    },

    // update (dt) {},
});
